import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LianBao
 * Date: 2024-09-03
 * Time: 21:00
 */
public class demo1 {
    public static void main(String[] args) throws InterruptedException {
        BlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(5);
        //如果队列为空,去take,会阻塞
        queue.take();
        //如果满了还继续put,会阻塞
        queue.put(1);
        System.out.println("put成功");
        queue.put(1);
        System.out.println("put成功");
        queue.put(1);
        System.out.println("put成功");
        queue.put(1);
        System.out.println("put成功");
        queue.put(1);
        System.out.println("put成功");
        queue.take();
        queue.put(1);
        System.out.println("put成功");
    }
}
